<template>
    <div class="container">
        <!-- 
            采用iview 的面板和卡片，参考文档
            卡片：https://www.iviewui.com/components/card
            折叠面板：https://www.iviewui.com/components/collapse
         -->
        <Collapse class="Collapse" v-model="value1">
            <Panel name="1">
                首页-轮播图
                <template slot="content">
                    <Card style="width:300px;float:left;margin:0 10px 10px 0" v-for="(item,index) in flash_img" :key="index">

                        <Button slot="extra" type="error" v-on:click="remove(item.uid)">删除</Button>

                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            轮播图
                        </p>
                        <img style="width: 100%" :src="'$api'+item.ad_value" alt="">
                    </Card>
                    <Card style="width:300px;float:left;margin:0 10px 10px 0">
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            轮播图-新增
                        </p>
                        <Upload multiple type="drag" name="ad" action="$api/api/upload/ad" :on-success="uploadSuccess" :on-error="uploadError">
                            <div style="padding: 2px 0">
                                <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                                <p>点击或拖拽文件进行上传</p>
                            </div>
                        </Upload>
                    </Card>
                </template>
            </Panel>
            <Panel name="2">
                首页-关于我们
                <template slot="content">
                    <!-- 图标 -->
                    <Card style="width:200px;float:left;margin:0 10px 10px 0">
                        <Upload slot="extra" name="ad" action="$api/api/upload/ad" :show-upload-list="false" :on-success="uploadSuccess2"
                            :on-error="uploadError">
                            <Button type="primary">修改</Button>
                        </Upload>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            图标
                        </p>
                        <img style="width: 100%" :src="'$api'+index_about_us_img" alt="">
                    </Card>
                    <!-- 首页关于我们查看更多按钮的链接 -->
                    <Card style="width:300px;float:left;margin:0 10px 10px 0">
                        <Button type="primary" slot="extra" @click.stop="update('index_abount_us_url',index_abount_us_url)">修改</Button>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            链接
                        </p>
                        <Input v-model="index_abount_us_url" placeholder="首页->关于我们->查看更多链接" style="width: 100%"></Input>
                    </Card>
                    <!-- 首页关于我们文字描述 -->
                    <Card style="width:500px;float:left;margin:0 10px 10px 0">
                        <Button type="primary" slot="extra" @click.stop="update('index_about_us_content',index_about_us_content)">修改</Button>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            文字描述
                        </p>
                        <Input v-model="index_about_us_content" type="textarea" :rows="7" placeholder="请输入首页-关于我们的介绍"></Input>
                    </Card>

                    <!-- 轮播 -->
                    <Card style="width:300px;float:left;margin:0 10px 10px 0" v-for="(item,index) in index_about_us_banner" :key="index">

                        <Button slot="extra" type="error" v-on:click="remove(item.uid)">删除</Button>

                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            轮播图
                        </p>
                        <img style="width: 100%" :src="'$api'+item.ad_value" alt="">
                    </Card>
                    <Card style="width:300px;float:left;margin:0 10px 10px 0">
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            轮播图-新增
                        </p>
                        <Upload multiple type="drag" name="ad" action="$api/api/upload/ad" :on-success="uploadSuccess1" :on-error="uploadError">
                            <div style="padding: 2px 0">
                                <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                                <p>点击或拖拽文件进行上传</p>
                            </div>
                        </Upload>
                    </Card>
                </template>
            </Panel>
            <Panel name="5">
                首页-新闻动态
                <template slot="content">
                    <!-- 图标 -->
                    <Card style="width:200px;float:left;margin:0 10px 10px 0">
                        <Upload slot="extra" name="ad" action="$api/api/upload/ad" :show-upload-list="false" :on-success="uploadSuccess3"
                            :on-error="uploadError">
                            <Button type="primary">修改</Button>
                        </Upload>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            图标
                        </p>
                        <img style="width: 100%" :src="'$api'+index_news_img" alt="">
                    </Card>
                    <!-- 目录 -->
                    <Card style="width:300px;float:left;margin:0 10px 10px 0">
                        <Button slot="extra" type="primary" @click="submit_index_news">修改</Button>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            目录
                        </p>
                        <Cascader class="Cascader" transfer :data="menu" v-model="index_news_uid[0]"></Cascader>
                        <Cascader class="Cascader" transfer :data="menu" v-model="index_news_uid[1]"></Cascader>
                        <Cascader class="Cascader" transfer :data="menu" v-model="index_news_uid[2]"></Cascader>
                    </Card>
                </template>
            </Panel>
            <Panel name="3">
                首页-产品研发
                <template slot="content">
                    <Card v-for="(item,index) in development_val" :key="index" style="width:280px;float:left;margin:0 10px 10px 0">
                        <Button slot="extra" @click="submit_index_development(index)" type="primary">修改</Button>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            产品研发
                        </p>
                        <Input class="Cascader" v-model="item.str1" placeholder="产品研发模块一广告语" style="width: 100%"></Input>
                        <Input class="Cascader" v-model="item.str2" placeholder="产品研发模块一广告语" style="width: 100%"></Input>
                        <p>背景图片：</p>
                        <img style="width:100%" :src="'$api'+item.img" alt="">
                        <Upload name="ad" action="$api/api/upload/ad" :show-upload-list="false" :data="{info:index}" :on-success="uploadSuccess4"
                            :on-error="uploadError" style="width:100px;margin:0 auto;">
                            <Button type="primary">上传背景图片</Button>
                        </Upload>
                    </Card>
                    <!-- 图标 -->
                    <Card style="width:200px;float:left;margin:0 10px 10px 0">
                        <Upload slot="extra" name="ad" action="$api/api/upload/ad" :show-upload-list="false" :on-success="uploadSuccess5"
                            :on-error="uploadError">
                            <Button type="primary">修改</Button>
                        </Upload>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            图标
                        </p>
                        <img style="width: 100%" :src="'$api'+index_development_img" alt="">
                    </Card>
                </template>
            </Panel>
            <Panel name="6">
                首页-产品展示
                <template slot="content">
                    <!-- 图标 -->
                    <Card style="width:200px;float:left;margin:0 10px 10px 0">
                        <Upload slot="extra" name="ad" action="$api/api/upload/ad" :show-upload-list="false" :on-success="uploadSuccess7"
                            :on-error="uploadError">
                            <Button type="primary">修改</Button>
                        </Upload>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            图标
                        </p>
                        <img style="width: 100%" :src="'$api'+index_product_img" alt="">
                    </Card>
                    <Card style="width:300px;float:left;margin:0 10px 10px 0">
                        <Button slot="extra" type="primary" @click="submit_show_product">保存</Button>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            展示商品
                        </p>
                        <Select v-model="show_product_uid" filterable transfer multiple style="width:260px">
                            <Option v-for="item in product_list" :value="item.value" :key="item.value">{{ item.label }}</Option>
                        </Select>
                    </Card>
                </template>
            </Panel>
            <Panel name="4">
                首页-招商加盟
                <template slot="content">
                    <Card v-for="(item,index) in index_join_us_val" :key="index" style="width:280px;float:left;margin:0 10px 10px 0">
                        <Button slot="extra" type="primary" @click="submit_join_us(index)">修改</Button>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            信息
                        </p>
                        <Input class="Cascader" v-model="item.str" placeholder="请输入文本描述" style="width: 100%"></Input>
                        <Input class="Cascader" v-model="item.class" placeholder="请输入ICON类名" style="width: 100%"></Input>
                    </Card>
                    <!-- 图标 -->
                    <Card style="width:200px;float:left;margin:0 10px 10px 0">
                        <Upload slot="extra" name="ad" action="$api/api/upload/ad" :show-upload-list="false" :on-success="uploadSuccess6"
                            :on-error="uploadError">
                            <Button type="primary">修改</Button>
                        </Upload>
                        <p slot="title">
                            <Icon type="ios-film-outline"></Icon>
                            图标
                        </p>
                        <img style="width: 100%" :src="'$api'+index_join_us_img" alt="">
                    </Card>

                </template>
            </Panel>
        </Collapse>
    </div>
</template>
<style lang="less" scoped>
    .container {
        width: 1200px;
        margin: 20px auto;
        .Cascader {
            margin-bottom: 10px;
        }
    }
</style>

<script>
    export default {
        data() {
            return {
                value1: '1',
                flash_img: [],
                index_about_us_banner: [],
                index_about_us_content: '',
                index_about_us_img: '',
                index_abount_us_url: '',
                index_news_img: '',
                index_news_uid: [],
                old_index_news_uid: [],
                menu: [],
                development_val: [],
                index_development_img: '',
                index_join_us_img: '',
                index_join_us_val: [],
                index_product_img: '',
                show_product_uid: [],
                product_list: [],
            }
        },
        methods: {
            /**
             * @function 轮播图上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'flash_img',
                            ad_value: response.store_result,
                            ad_remake: '首页flash图片',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 0
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            if (response.data.state > 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 关于我们轮播图上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess1: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_about_us_banner',
                            ad_value: response.store_result,
                            ad_remake: '首页关于我们的轮播',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 0
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 关于我们LOGO上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess2: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_about_us_img',
                            ad_value: response.store_result,
                            ad_remake: '关于我们LOGO',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 1
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 新闻动态图片上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess3: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_news_img',
                            ad_value: response.store_result,
                            ad_remake: '首页新闻动态图片',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 1
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 新闻动态图片上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess4: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.development_val[0].img = response.store_result
                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 首页产品研发LOGO上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess5: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_development_img',
                            ad_value: response.store_result,
                            ad_remake: '首页产品研发LOGO',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 1
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 首页招商加盟LOGO上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess6: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_join_us_img',
                            ad_value: response.store_result,
                            ad_remake: '首页招商加盟LOGO',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 1
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 首页产品研发LOGO上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess5: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_development_img',
                            ad_value: response.store_result,
                            ad_remake: '首页产品研发LOGO',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 1
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 首页产品展示LOGO上传成功
             * @param {object} reponse - 服务器返回的信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             * 
             */
            uploadSuccess7: function (response, file, fileList) {
                let that = this
                if (response.state == '1') {
                    that.$axios.post(this.$api+'/api/admin/adSet', {
                            ad_name: 'index_product_img',
                            ad_value: response.store_result,
                            ad_remake: '首页产品展示LOGO',
                            ad_rate: 0,
                            ad_pos: 'index',
                            only: 1
                        }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                        .then(function (response) {
                            
                            if (response.data.state >= 1) {
                                that.$Message.success('上传成功');
                            } else {
                                that.$Message.error('上传失败');

                            }
                        })
                        .catch(function (response) {
                            that.$Message.error('上传失败');
                        })

                } else {
                    this.$Message.error('上传失败');
                }
            },
            /**
             * @function 上传图片出错，通用
             * @param {object} error - 错误信息
             * @param {object} file - 文件信息
             * @param {Array<Object>} fileList - 文件信息列表
             */
            uploadError: function (error, file, fileList) {
                this.$Message.error('上传失败');
            },
            /**
             * @param {number} uid - 要删除的广告的uid
             * @function 删除广告
             */
            remove: function (uid) {
                let that = this
                this.$axios.post(this.$api+'/api/admin/adDel', {
                        uid: uid
                    }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                    .then(function (response) {
                        if (response.data.state > 0) {
                            that.$Notice.success({
                                title: '删除成功',
                                desc: ''
                            });
                        } else {
                            that.$Notice.error({
                                title: '删除失败',
                                desc: ''
                            });
                        }
                    })
                    .catch(function (response) {
                        that.$Notice.error({
                            title: '删除失败',
                            desc: ''
                        });
                    })
            },
            /**
             * @function 更新广告内容，仅适用于不可重复的广告
             * @param {string} ad_name 广告变量名
             * @param {String} ad_value 广告值
             */
            update: function (ad_name, ad_value) {
                let that = this
                this.$axios.post(this.$api+'/api/admin/adUpdate', {
                        ad_name: ad_name,
                        ad_value: ad_value
                    }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                    .then(function (response) {
                        if (response.data.state == 1) {
                            that.$Notice.success({
                                title: '修改成功',
                                desc: ''
                            });
                        } else {
                            that.$Notice.error({
                                title: '修改失败',
                                desc: ''
                            });
                        }
                    })
                    .catch(function (response) {
                        that.$Notice.error({
                            title: '修改失败',
                            desc: ''
                        });
                    })
            },
            /**
             * @function 更新广告内容，仅适用于不可重复的广告
             * @param {string} uid-Uid
             * @param {String} ad_value-广告值
             */
            updateUid: function (uid, ad_value) {
                let that = this
                this.$axios.post(this.$api+'/api/admin/adUpdate', {
                        uid: uid,
                        ad_value: ad_value
                    }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                    .then(function (response) {
                        if (response.data.state == 1) {
                            that.$Notice.success({
                                title: '修改成功',
                                desc: ''
                            });
                        } else {
                            that.$Notice.error({
                                title: '修改失败',
                                desc: ''
                            });
                        }
                    })
                    .catch(function (response) {
                        that.$Notice.error({
                            title: '修改失败',
                            desc: ''
                        });
                    })
            },
            /**
             * @function 更新首页新闻动态分类
             */
            submit_index_news: function () {
                /**
                 * @function 通过判断修改前和修改后的UID，如果一致则不更改，不一致则更改（如果没发生更改，Laravel 返回的修改行数为0，会导致修改失败  ）
                 */
                this.index_news_uid.forEach((element, index) => {
                    if (element[element.length - 1] != this.old_index_news_uid[index].ad_value) {
                        this.updateUid(this.old_index_news_uid[index].uid, element[element.length - 1])
                    }
                })
            },
            /**
             * @function 更新首页产品研发的广告
             * @param {int} index 更新第几个广告
             */
            submit_index_development: function (index) {
                let ad_value = [this.development_val[index].str1, this.development_val[index].str2, this.development_val[
                    index].img].join("||")
                if (ad_value != this.development_val[index].old) {
                    this.updateUid(this.development_val[index].uid, ad_value)
                }


            },
            /**
             * @function 更新首页招商加盟的广告位
             * @param {int} index 更新第几个广告
             */
            submit_join_us: function (index) {
                let ad_value = [this.index_join_us_val[index].str, this.index_join_us_val[index].class].join("||")
                if (ad_value != this.index_join_us_val[index].old) {
                    this.updateUid(this.index_join_us_val[index].uid, ad_value)
                }
            },
            /**
             * @function 更新首页->产品展示
             */
            submit_show_product: function () {
                this.update('show_product_uid', this.show_product_uid.join("||"))
            }
        },
        created: function () {
            let that = this
            this.$axios.get(this.$api+'/api/admin/MenuGet', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    that.menu = response.data.menu
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=flash_img', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.flash_img = response.data.list
                })
                .catch(function (response) {
                    
                })

            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_about_us_banner', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_about_us_banner = response.data.list
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_about_us_content', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_about_us_content = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_about_us_img', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_about_us_img = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_abount_us_url', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_abount_us_url = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_news_img', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_news_img = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })

            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_news_uid', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.old_index_news_uid = response.data.old
                    response.data.list.forEach((element, index) => {
                        let arr = element.reverse()
                        for (let i in arr) {
                            arr[i] = arr[i].uid
                        }
                        response.data.list[index] = arr
                    });

                    that.index_news_uid = response.data.list
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_development_img', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_development_img = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })

            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=development_val', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    for (let i in response.data.list) {
                        let _arr = response.data.list[i].ad_value.split('||')
                        that.development_val.push({
                            old: response.data.list[i].ad_value,
                            uid: response.data.list[i].uid,
                            str1: _arr[0],
                            str2: _arr[1],
                            img: _arr[2]
                        })
                    }

                })
                .catch(function (response) {})
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_join_us_img', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_join_us_img = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_join_us_val', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    let _arr = response.data.list
                    _arr.forEach((element, index) => {
                        let arr = element.ad_value.split("||")
                        that.index_join_us_val.push({
                            str: arr[0],
                            class: arr[1],
                            old: element.ad_value,
                            uid: element.uid
                        })
                    })
                })
                .catch(function (response) {
                    
                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=index_product_img', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    
                    that.index_product_img = response.data.list[0].ad_value
                })
                .catch(function (response) {
                    
                })
            
            this.$axios.post(this.$api+'/api/admin/goodsGet', {
                    uid: 0,
                    keyWord: ''
                }, {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    console.log('miao')
                    for (let i in response.data.list) {
                        response.data.list[i].value = response.data.list[i].uid
                        response.data.list[i].label = response.data.list[i].goods_name
                    }
                    that.product_list = response.data.list
                    that.show_product_uid.push('0')
                })
                .catch(function (response) {

                })
            this.$axios.get(this.$api+'/api/admin/adGet?ad_name=show_product_uid', {
                        headers: {
                            'Access-Control-Request-Method': 'Origin'
                        },
                        withCredentials: true
                    })
                .then(function (response) {
                    console.log('wang');

                    response.data.list[0].ad_value.split('||').forEach(element => {
                        that.show_product_uid.push(parseInt(element))
                    })
                })
                .catch(function (response) {
                    
                })

        },
    }
</script>